import router from '@/router'
import {post} from '@/util/request'

export default {
	namespace:'fleetSummary',
	namespaced:true,
	state:{
		isLoading:false,
    pageData:{},
    totalData:{}
	},
	mutations:{
    changeLoading(state,v){
      state.isLoading = v;
    },
    changePagedata(state,v){
      state.pageData = v;
    },
    changeTotaldata(state,v){
      state.totalData = v;
    }
	},
	actions:{
    async reload({commit},query){
      commit('changeLoading',true);
      let res = await post('/stat/teamTotalStat/orgStatList',query);
      commit('changePagedata',res.data.data);
      let tes = await post('/stat/teamTotalStat/orgStatSum',query);
      commit('changeTotaldata',tes.data.data);
      commit('changeLoading',false);
    }
	},
	subscriptions({dispatch},router){
		//给路由加监听一旦进入module绑定的页面时dispatch初始化action
		router.afterEach((to,from)=>{
			if(to.name === this.namespace){

			}
		})
	}
}
